home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
diskutil
/
noahdi.zoo
/
noahdi
/
hd_inst.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-24
|
24KB
|
626 lines
/*
File: HD_INST.C Harddisk Driver Installer. AHDI Compatible.
*/
/*
Copyright (c) 1988 - 1991 by Ted Schipper.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation.
This software is provided AS IS with no warranties of any kind. The author
shall have no liability with respect to the infringement of copyrights,
trade secrets or any patents by this file or any part thereof. In no
event will the author be liable for any lost revenue or profits or
other special, indirect and consequential damages.
*/
#include "bootsec.h"
#include "hddriver.h"
#include "system.h"
#include <osbind.h>
#include <bios.h>
/***************************************************************************
Installer
-----------
HISTORY
---------
Feb 1989. THS. Started. Tested ppu, pread, getbpb. Made some corrections
to bootsector structure (allignment). Added a dirty
vector installer with hd debug messages.
Mar 1989. THS. Added pool_install.
Apr 1989. THS. Removed dirty vector installer. Added normal installer,
exec_res, exec_auto stuff.
May 1989. THS. Added some extra stuff to pread. Pread now generates an
error when a non existing drive is selected on a
existing controller. Can be done better.
Jun 1989. THS. Runs nice (still from auto folder). Added assembly startup
code to get it compatible Atari HD boot. Seems to work OK.
V0.00
***************************************************************************/
/***************************************************************************
Global Variables
***************************************************************************/
extern short puns;
extern struct bpb bpbs[];
extern struct hd_drv pun[];
extern func o_init;
extern func o_bpb;
extern func o_rw;
extern func o_mediach;
extern short hd_boot_flg;
extern long base_pg_addr;
/* Initialize variables to get them into the driver code */
short clun = 0; /* current logical unit */
short cpun = 0; /* current physical unit */
short installed = 0; /* number of installed partitions */
long cdbit = 0; /* current drive bit */
struct hd_boot pbuf, lbuf; /* sector buffers */
char *copy_msg =
"----------------------------\r\n\
ASCI/SCSI Hard Disk Driver\r\n\
NOAHDI V0.00 Sept-26-1989\r\n\
by T.Schipper Installed\r\n\
----------------------------\r\n";
char *env_str = "PATH=\0C:\\\0"; /* enviroment string */
char *nothing = "\0"; /* empry string */
char *auto_path = "C:\\AUTO\\*.PRG"; /* search string for Fsfirst */
char *command = "COMMAND.PRG"; /* prg to execute if comload is true */
long auto_base_pg = 0L; /* temp storage for basepage addr */
char dta[44] = {0,0}; /* DTA buffer */
char exec_path[32] = {0,0}; /* filename build string */
char *dvr_nld =
"Hard disk driver not loaded; hit RETURN\r\nkey to continue:\r\n";
char *dsk_bsd = "*** WARNING ***\r\n\a\
This hard disk driver may not work with\r\n\a\\
a disk-based version of TOS; files on\r\n\a\
your hard disk may be damaged.\r\n\a\r\n\a";
char *unf_rel = "*** WARNING ***\r\n\a\
You are using an unofficial ROM release\r\n\a\
of the operating system. This driver\r\n\a\
may not work correctly with it. Files\r\n\a\
on your hard disk may be damaged.\r\n\a\r\n\a";
struct rom_rev {
long rel_date; /* ROM release date */
long pool_list; /* free list addr of release */
};
struct rom_rev revtable[4] = { 0x11201985L, 0x000056FAL,
0x02061986L, 0x000056FAL,
0x04241986L, 0x000056FAL,
0x00000000L, 0x00000000L
};
/***************************************************************************
Installer
***************************************************************************/
/***************************************************************************
*
* Function name : exec_res. Execute memory resident programs.
* Parameters : None
* Returns : None
* Description : Check physical memory every 512 bytes for a long magic
* number. If magic number found, check if next long points
* to magic number. If pointer to magic number is valid,
* calculate the checksum of the first 256 words. If the
* check is magic too, execute memory resident program at
* the address specified in the 3rd long.
* Comments :
*/
void exec_res()
{
func res_prg;
unsigned short checksum;
short *chksum_ptr, i;
long *mem_ptr;
mem_ptr = (long *)PHYSTOP; /* get end of memory */
while ((mem_ptr -= 0x80) > (long *)0x0400L)
{ /* dec 512 bytes, untill 0x600, then */
if (*mem_ptr == 0x12123456L) /* magic long word at 512b boundary */
{
if (*(mem_ptr + 1) == (long)mem_ptr) /* pointer to magic OK */
{
checksum = 0; /* clear checksum */
chksum_ptr = (short *)mem_ptr; /* set pointer to first word */
for (i=0; i<256; i++) /* calc checksum from 256 words */
checksum += *chksum_ptr++;
if (checksum == 0x5678) /* is the checksum magic */
{
res_prg = (func)*(mem_ptr + 2); /* set pointer to entry point */
(*res_prg)(); /* execute memory resident programm */
}
}
}
}
}
/***************************************************************************
*
* Function name : exec_auto_prg. Start auto-folder execute process.
* Parameters : None
* Returns : None
* Description : Create a basepage for, and start the auto-folder program
* which executes all the programs in the auto folder.
* Comments : Since we can't read the micro registers, the basepage
* address is stored in a global variable. This variable
* is used by the auto-folder executer to find its basepage.
*/
void exec_auto_prg()
{
void auto_prg();
long *basepage;
basepage = (long *)Pexec(5,nothing,nothing,nothing); /* create a basepage */
*(basepage + 2) = (long)auto_prg; /* set process start address */
auto_base_pg = (long)basepage; /* save basepage address */
Pexec(4,nothing,basepage,nothing); /* execute auto_prg as a process */
}
/***************************************************************************
*
* Function name : auto_prg. Auto folder search and execute program.
* Parameters : None
* Returns : None
* Description : Search the auto folder for programs. Execute each found
* program. Set SYSBASE variable. Check if command load
* flag is set, and execute command.prg if set. Else build
* a basepage and execute the AES.
* Comments :
*/
void auto_prg()
{
char *ptr_s, *ptr_d, *ptr_m;
long *base_page;
func reset;
Dsetdrv(2); /* set the default drive to C: */
Super(auto_base_pg + 0x100L); /* supervisor mode, stack at end of basepage */
if (Mshrink(auto_base_pg,0x100L) == 0); /* return unused memory */
{
Fsetdta(dta); /* set disk transfer address */
if (Fsfirst(auto_path,7) == 0) /* check for auto prg's */
{
do
{
ptr_s = auto_path;
ptr_d = exec_path;
ptr_m = &auto_path[8];
while (ptr_s != ptr_m) /* copy C:\AUTO\ to exec filename string */
*ptr_d++ = *ptr_s++;
ptr_s = &dta[30]; /* ptr to found program filename */
while(*ptr_s != 0) /* copy filename from dta buffer */
*ptr_d+